package cn.com.huaxun.module.user.service.impl;

import cn.com.huaxun.base.datasource.DataSourceNames;
import cn.com.huaxun.base.datasource.annotation.DataSource;
import cn.com.huaxun.base.kafka.config.KafkaTemplateSender;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.huaxun.module.user.dao.StudentDao;
import cn.com.huaxun.module.user.entity.StudentEntity;
import cn.com.huaxun.module.user.service.StudentService;

/**
 * @descripe：学生业务层
 * @company：南京华讯方舟通讯设备有限公司
 * @author：zhoujinbing
 * @time：2019/1/2 10:01
 * @version：V1.0
 */
@Service("studentService")
@com.alibaba.dubbo.config.annotation.Service
public class StudentServiceImpl extends ServiceImpl<StudentDao, StudentEntity> implements StudentService {

    @Autowired
    private KafkaTemplateSender<StudentEntity> kafkaTemplateSender;

    @Override
    public void insertStudent(StudentEntity studentEntity) {
        this.baseMapper.insert(studentEntity);
    }

    @Override
    @DataSource(name = DataSourceNames.FIRST)
    public StudentEntity selectById(Long id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public void sendKafkaMessage(String topic, StudentEntity studentEntity) {
        kafkaTemplateSender.send(topic,studentEntity);
    }
}
